﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
namespace Guoc.DAL.Common
{
    /// <summary>
    /// 数据访问基本方法
    /// </summary>
    /// <typeparam name="T"></typeparam>
   public interface IDataAccess<T>:IBase
    {
       /// <summary>
       /// 创建一个实体
       /// </summary>
       /// <param name="t"></param>
       /// <returns></returns>
       bool Create(T t);
       /// <summary>
       /// 修改单个实体
       /// </summary>
       /// <param name="t"></param>
       /// <returns></returns>
       bool Update(T t);
       /// <summary>
       /// 删除单个实体
       /// </summary>
       /// <param name="t"></param>
       /// <returns></returns>
       bool Delete(T t);
       /// <summary>
       /// 获取单个实体
       /// </summary>
       /// <param name="id"></param>
       /// <returns></returns>
       T Get(object id);
       /// <summary>
       /// 判断某列,或某实体属性值是否存在
       /// </summary>
       /// <param name="columnName">列名，属性名</param>
       /// <param name="value">值</param>
       /// <returns></returns>
       bool IsExists(string columnName, string value);
       /// <summary>
       /// 获取所有列表记录
       /// </summary>
       /// <returns></returns>
       List<T> GetList();
       /// <summary>
       /// 获取分页列表记录
       /// </summary>
       /// <param name="page">当前页</param>
       /// <param name="rows">每页显示记录行数</param>
       /// <param name="count">记录总数</param>
       /// <returns></returns>
       List<T> GetList(int page, int rows,out int count);

       /// <summary>
        /// 执行原生Sql语句。示例：query="Delete from sys_Role where id in ('qq','ee')"; 
        /// </summary>
        /// <param name="query">SQL语句</param>
        /// <returns></returns>
      // bool ExecuteSql(string query);

       /// <summary>
       /// Linq查询接口
       /// </summary>
       IQueryable<T> LinqQuery { get; }

       /// <summary>
       /// 条件查询
       /// </summary>
       ICriteria ConditionQuery { get; }
    }
}
